<!--<a href="#/layui/busiguanli" class="layui-btn layui-btn-xs layui-btn-primary" style="margin: 20px 0 0 100px;">
  <i class="layui-icon">&#xe65c;</i>
</a>-->

<form action="" class="layui-form">
<div class="layui-container">
	<div class="layui-row">
    <div class="layui-col-md10">
      <h2 class="title">
      	<a href="#/layui/busiguanli" class="layui-btn layui-btn-xs layui-btn-primary" style="margin: -0px 0 0 0;border: none;background-color: rgba(0,0,0,0);">
				  <i class="layui-icon">&#xe65c;</i>
				</a>
      	商圈详情</h2>
      
      
      
      	
      	
      	<table class="layui-table" lay-size="lg">
		      
		      <tbody>
		      	<tr>
		      		<td>商圈名称：</td>
		      		<td>
		      			<input type="text" name="busiName" class="layui-input busiName" >
		      		</td>
		      	</tr>
		      	<tr>
		      		<td>商圈人数：</td>
		      		<td>
		      			<input type="text" name="busiMemNum" class="layui-input busiMemNum" >
		      		</td>
		      	</tr>
		      	<tr>
		      		<td>商圈星级：</td>
		      		<td>
		      			<input type="text" name="busiStar" class="layui-input busiStar" >
		      		</td>
		      	</tr>
		      	<tr>
		      		<td>商圈区域：</td>
		      		<td>
		      			<input type="text" name="busiArea" class="layui-input busiArea" >
		      		</td>
		      	</tr>
		      	<tr>
		      		<td>商圈所属分会：</td>
		      		<td>
		      			<input type="text" name="busiFenhui" class="layui-input busiFenhui" >
		      		</td>
		      	</tr>
		      	<tr>
		      		<td>分会介绍：</td>
		      		<td><textarea name="" placeholder="请输入" class="layui-textarea"></textarea></td>
		      	</tr>
		      	<tr>
		      		<td>分会照片：</td>
		      		<td>
		      			<table class="layui-table" lay-skin="nob">
		      				<tr>
		      					<td>
		      						<button type="button" class="layui-btn addPic" id="test1">
									  <i class="layui-icon">&#xe67c;</i>添加图片
									</button>
		      					</td>
		      					<td>
		      						<table class="layui-table" lay-skin="nob">
		      							<tr>
		      								<td><input type="text" name="picTitle" class="layui-input picTitle" placeholder="图片标题" ></td>
		      								<td><button class="layui-btn layui-btn-danger delPic">删除</button></td>
		      							</tr>
		      						</table>
		      					</td>
		      				</tr>
		      			</table>
		      		</td>
		      	</tr>
		      	<tr>
		      		<td>是否禁止：</td>
		      		<td><select name="isForbidden" lay-verify="" class="isForbidden">
									  <option value="1">是</option>
									  <option value="0">否</option>
									</select> </td>
		      	</tr>
			  </tbody>
		      	
	      </table>
    </div>
    
    <div class="layui-col-md10">
    	<div class="addFHBtn">
			<button class="layui-btn comfirm" type="button">确定</button>
		</div>
    </div>
    
  </div>
</div>




</form>

<script type="text/javascript">
	let busiName = document.querySelector(".busiName");
	let busiMemNum = document.querySelector(".busiMemNum");
	let busiStar = document.querySelector(".busiStar");
	let busiArea = document.querySelector(".busiArea");
	let busiFenhui = document.querySelector(".busiFenhui");
	let addPic = document.querySelector(".addPic");
	let delPic = document.querySelector(".delPic");
	let isForbidden = document.querySelector(".isForbidden");
	let picTitle = document.querySelector(".picTitle");
	let confirm = document.querySelector(".comfirm");
	
	layui.use(['jquery', 'mockjs', 'table', 'sidebar', 'form','route'], function () {
		var $ = layui.jquery,
      layer = layui.layer,
      table = layui.table,
      sidebar = layui.sidebar,
      route = layui.route,
      params = route.params(),
      form = layui.form;
      
      function renderForm(){
		  layui.use('form', function(){
		   var form = layui.form;//高版本建议把括号去掉，有的低版本，需要加()
		   form.render();
		  });
		}
    	
    	renderForm();
      
      
    let _obj = {
					  "Guid": "00000000-0000-0000-0000-000000000000",
					  "MemLoginId": "sample string 2",
					  "Name": busiName.value,
					  "Photo": addPic.value,
					  "Brief": picTitle.value,
					  "Area": busiArea.value,
					  "AreaCode": "",
					  "RankGuid": '00000000-0000-0000-0000-000000000000',
					  "CategoryId": 9,
					  "MemberCount": 10,
					  "InCircleGuid": '00000000-0000-0000-0000-000000000000',
					  "CreateUser": "sample string 11",
					  "CreateTime": "2018-12-19T11:56:29.0456022+08:00",
					  "IsAudit": 12,
					  "AuditTime": "2018-12-19T11:56:29.0456022+08:00",
					  "RankScore": 1,
					  "ModifyUser": "sample string 13",
					  "ModifyTime": "2018-12-19T11:56:29.0456022+08:00"
	     		}
      
      function _confirm (){
      	
						
						_obj.Name = busiName.value;
//						_obj.Photo = addPic.value;
//						_obj.Brief = picTitle.value;
//						_obj.Area = busiArea.value;
//						_obj.InCircleGuid = busiFenhui.value;
//						_obj.RankGuid = busiStar.value;
						
						
					
						if(params == null) {
							 
//							_obj.CreateTime = new Date();
							DBHelper.Post("Admin_Xn_Circle", _obj, function(data) {
								console.log(data)
							}, function(data) {
								console.log(data)
							});
						} else {
							_obj.Guid = params.id;
							_obj.Name = busiName.value;
							console.log(params.id)
//							_obj.ModifyTime = new Date();
							DBHelper.Put("Admin_Xn_Circle?id=" + params.id, _obj, function(data) {
								window.history.go(-1);
							}, function(data) {
								console.log(data)
							})
						}
					}
      
      
      if(params){
      	DBHelper.Get("Admin_Xn_Circle?id="+params.id,function(data){
      		console.log("data",data)
      		busiName.value=data.Name;
      		busiStar.value=data.InCircleGuid;
      		busiMemNum.value = data.MemberCount;
      		busiArea.value = data.Area;
      		
      		
      	},function(data){
      		console.log(data)
      	})
      }
      
      confirm.addEventListener("click",_confirm)
      
 })
	
	
	
</script>



	<style scoped>
      	.title{
      		/*margin-left: 30px;*/
      		margin-top: 30px;
      	}
      	.checkBtn{
      		border-radius: 5px;
      		width: 100px;
      	}
      	.listBtns{
      		display: flex;
      		justify-content: space-between;
      		width: 100%;
      	}
      	.listBtn{
      		border-radius: 5px;
      	}
      	.addFHBtn{
      		text-align: center;
      		margin-top: 20px;
      		margin-bottom: 20px;
      	}
      	.addFHBtn button{
      		display: inline-block;
      		width: 300px;
      	}
      </style>
      
      
